<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Device\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 录像机设备验证数据类
 */
class RdDeviceSerialRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'id',
            'rod_id',
            'online',
            'name',
            'voice_id',
            'comply_id',
            'url',
            'device_serial',
            'channel_no',
            'type',
            'stand_id',
            'sort',
            'remarks',
            'prompt_id',
            'addr',
            'created_at',
            'updated_at',
            'deleted_at'
        ],
        'create' => [
            'rod_id',
            'online',
            'name',
            'voice_id',
            'comply_id',
            'url',
            'device_serial',
            'channel_no',
            'type',
            'stand_id',
            'sort',
            'remarks',
            'prompt_id',
            'addr',
        ],
        'update' => [
            'rod_id',
            'online',
            'name',
            'voice_id',
            'comply_id',
            'url',
            'device_serial',
            'channel_no',
            'type',
            'stand_id',
            'sort',
            'remarks',
            'prompt_id',
            'addr',
        ]
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'id' => 'integer',
            //装置ID 验证
            'rod_id' => 'integer',
            //1上线 2下线 验证
            'online' => 'integer|in:1,2',
            //名称 验证
            'name' => 'max:255',
            //名称语音ID 验证
            'voice_id' => 'integer',
            //遵守语音ID 验证
            'comply_id' => 'integer',
            //设备类型 1:枪机 2:球机 验证
            'type' => 'integer|in:1,2',
            //站点id 验证
            'stand_id' => 'integer',
            //排序 验证
            'sort' => 'integer',
            //流媒体地址 验证
            'url' => 'array',
            //设备序列号 验证
            'device_serial' => 'max:255',
            //通道号 验证
            'channel_no' => 'max:255',
            //备注 验证
            'remarks' => 'max:255',
            //提示语ID 验证
            'prompt_id' => 'integer',
            //地址 验证
            'addr' => 'max:255',

        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => 'ID',
            'rod_id' => '装置ID',
            'online' => '在线状态',
            'name' => '名称',
            'voice_id' => '名称语音ID',
            'comply_id' => '遵守语音ID',
            'url' => '流媒体地址',
            'device_serial' => '设备序列号',
            'channel_no' => '通道号',
            'type' => '设备类型',
            'stand_id' => '站点ID',
            'sort' => '排序',
            'remarks' => '备注',
            'prompt_id' => '提示语ID',
            'addr' => '地址',
            'created_by' => '创建者',
            'updated_by' => '更新者',
            'deleted_at' => '删除时间',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',

        ];
    }

    public function messages(): array
    {
        return [
            'id.integer' => 'ID必须是整数',
            'rod_id.required' => '必填装置ID',
            'rod_id.integer' => '装置ID必须是整数',
            'online.required' => '必填在线状态',
            'online.integer' => '在线状态必须是整数',
            'online.in' => '在线状态只能是1(上线)或2(下线)',
            'name.required' => '必填名称',
            'name.max' => '名称长度不能超过255个字符',
            'voice_id.integer' => '名称语音ID必须是整数',
            'comply_id.required' => '必填遵守语音ID',
            'comply_id.integer' => '遵守语音ID必须是整数',
            'url.array' => '流媒体地址必须是数组',
            'device_serial.max' => '设备序列号长度不能超过255个字符',
            'channel_no.max' => '通道号长度不能超过255个字符',
            'type.required' => '必填设备类型',
            'type.integer' => '设备类型必须是整数',
            'type.in' => '设备类型只能是1(枪机)或2(球机)',
            'stand_id.required' => '必填站点ID',
            'stand_id.integer' => '站点ID必须是整数',
            'sort.required' => '必填排序',
            'sort.integer' => '排序必须是整数',
            'remarks.max' => '备注长度不能超过255个字符',
            'prompt_id.integer' => '提示语ID必须是整数',
            'addr.max' => '地址长度不能超过255个字符',
            'created_by.required' => '必填创建者',
            'updated_by.required' => '必填更新者',

        ];
    }
}